package com.neutech.maplestory.client.util;

import com.neutech.maplestory.client.constant.Constant;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

/**
 * CLASS:GameUtil：
 * TODU:加载图片，音频等静态资源的工具类
 * date:2021/1/27、17:01
 * version:0.1
 */
public class GameUtil {
    private GameUtil(){}

    /**
     *通过图片获取对象
     * @param imageName
     * @return返回图片对象
     */
    public static Image getImage(String imageName){
        URL url = GameUtil.class.getClassLoader().getResource(Constant.IMAGE_PATH_PRE+imageName+Constant.IMAGE_PATH_FIX);
        BufferedImage img = null;
        try {
            img = ImageIO.read(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return img;
    }
}
